import React from "react";

export class ErrorBoundary extends React.Component {
  constructor(props){
    super(props);
    this.state = {hasError: false};
  }

  static getDerivedStateFromError(error: any){
    return {hasError: true};
  }

  componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {
      sendLog(error, errorInfo)
  }

  render(): React.ReactNode {
    if(this.state.hasError){
      return <h1>Something went wrong.</h1>;
    }
    return this.props.children;
  }
}

function sendLog(error: Error, errorInfo: React.ErrorInfo) {
  throw new Error("Function not implemented.");
}

